/*
 * @description:
 * @version: 1.0.1
 * @Author: xuqiulin
 * @Date: 2021-06-16 17:21:59
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-06-21 11:51:50
 */
package server

import (
	"fmt"
	"net"
)

type IServer interface {
}

type Server struct {
	ln   net.Listener
	Port uint
}

func NewServer(port uint) IServer {
	ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
	if err != nil {
		fmt.Println("服务器监听失败...")
		return nil
	}
	s := &Server{
		Port: port,
		ln:   ln,
	}
	return s
}

func (this *Server) Start() {
	for {
		conn, err := this.ln.Accept()
		if err != nil {
			fmt.Println(err)
			continue
		}
		NewConn()
	}
}

func (this *Server) Stop() {

}
